using System;
using System.Collections.Generic;
using System.Text;

namespace Kenly.DBFramework.Gateway
{
    /// <summary>
    ///  Database factory to create instance of database interfaces.
    /// </summary>
    internal static class TableGatewayUtilityFactory<T> where T : TableGateway<T>, new()
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="databaseType"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public static ITableGatewayUtility<T> CreateInstance(DatabaseType databaseType, string connectionString)
        {
            ITableGatewayUtility<T> tableGatewayUtility = null;
            switch (databaseType)
            {
                case DatabaseType.SqlServer: tableGatewayUtility = new SqlTableGatewayUtility<T>(databaseType, connectionString);
                    break;
                case DatabaseType.Oracle: tableGatewayUtility = new OracleTableGatewayUtility<T>(databaseType, connectionString);
                    break;
                case DatabaseType.Oledb: tableGatewayUtility = new OleTableGatewayUtility<T>(databaseType, connectionString);
                    break;
                default: tableGatewayUtility = new SqlTableGatewayUtility<T>(databaseType, connectionString);
                    break;
            }
            return tableGatewayUtility;
        }

    }
}
